import { _decorator, Component, Label, tween, UIOpacity, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('BCToastBase')
export class BCToastBase extends Component {
	@property(Label)
	private m_lblToast: Label = null;

	@property(UIOpacity)
	private m_bg: UIOpacity = null;

    _showToast(text: string){
		this.m_bg.opacity = 0;
		this.m_lblToast.string = text;
		this.m_bg.node.position = v3(0, -200);

		const showTime = 3;

		tween(this.m_bg.node).to(0.2, { position: v3(0, 0) }).delay(showTime).to(0.2, {position: v3(0, 200)}).start();
		tween(this.m_bg).to(0.2, { opacity: 255 }).delay(showTime).to(0.2, { opacity: 0 }).call(() => {
			this.node.destroy();
		}).start();
	}
}

